import MeasureItem from './MeasureItem'
//import Calc from './Calc'
//import DateUtils from '../utils/DateUtils'
import BodyFat from './Bodyfat'
//const UI = require('./UI')

const DESC = "体内所含脂肪的重量。";
const isHmStandInterval = false;
//const BAR = [UI.color.report_lower, UI.color.report_stand, UI.color.report_higher, UI.color.report_highest]
    /**
     * 脂肪重量 计算方法：脂肪重量=体 重*脂肪比例
     * 计算脂肪重量
     */
export default class BFWReport {
    static calcFfm(measure) {
        return (measure.weight * (measure.bodyfat / 100)).toFixed(2)
    }

  static isEnable(measure) {
    return true
  }
  static build(measure) {
    const item = new MeasureItem();
    const value = BFWReport.calcFfm(measure);
    if (!value || value == 0) {
      return null;
    }
    const bodyFatData = BodyFat.build(measure);

    const boundaries = measure.gender == 1 ? [1.5, 2.5, 4] : [1, 2, 3.5];
    const level = bodyFatData.level;
    const isStand = bodyFatData.isStand;
    let levelName = [];

    if (isHmStandInterval) {
      levelName = ["偏瘦", "正常", "肥胖"]
    } else {
      levelName = ["偏低", "标准", "偏高", "严重偏高"]
    }

    item.key = 'bfw'
    item.name = "脂肪重量";
    item.boundaries = boundaries;
    item.value = value;
    item.levelNames = levelName;
    item.isStand = isStand;
    item.unit = "kg";
    item.desc = DESC;
    item.level = level;
    item.bar = bodyFatData.bar;
    item.showBar = false;
    item.min = 5;
    item.max = measure.gender == 1 ? 45 : 35;

    // if (!isStand) {
    //   let offset = 0
    //   if (level < STAND_LEVEL) {
    //     offset = value - boundaries[STAND_LEVEL - 1]
    //   } else {
    //     offset = value - boundaries[STAND_LEVEL]
    //   }
    //   item.offset = offset
    // }

    return item
  }


}
